package org.zht.dormpro.dorm.cacher.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.zht.dormpro.dorm.aop.annotation.GetCache;
import org.zht.dormpro.dorm.cacher.IDormCacher;
import org.zht.dormpro.dorm.mapper.TbDormMapper;
import org.zht.dormpro.dorm.model.TbDorm;
import org.zht.dormpro.pub.constant.CacheKey;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@Repository
public class DormCacherImpl implements IDormCacher {

    @Autowired
    private TbDormMapper dormMapper;
    @Override
    @GetCache(key = CacheKey.Bed_LIST_KEY ,fieldKey = "#dormId")
    public List<HashMap<String, Object>> getAllBed(String dormId) {
        HashMap<String,Object> map1 = new HashMap<>();
        HashMap<String,Object> map2= new HashMap<>();
        HashMap<String,Object> map3 = new HashMap<>();
        HashMap<String,Object> map4 = new HashMap<>();
        HashMap<String,Object> map5 = new HashMap<>();
        map1.put("id",1);
        map1.put("name","床铺1");
        map2.put("id",2);
        map2.put("name","床铺2");
        map3.put("id",3);
        map3.put("name","床铺3");
        map4.put("id",4);
        map4.put("name","床铺4");
        map5.put("id",5);
        map5.put("name","床铺5");
        map5.put("id",6);
        map5.put("name","床铺6");
        List<HashMap<String,Object>> list = new ArrayList<>();
        list.add(map1);
        list.add(map2);
        list.add(map3);
        list.add(map4);
        list.add(map5);
        return list;
    }

    @Override
    public List<TbDorm> getDormByFloorId(String floorId) {
       return dormMapper.getAllDormByFloorId(floorId);
    }
}
